package com.dream.testtubebaby.data.user;

import org.json.JSONException;
import org.json.JSONObject;

public class UserInfo {
	// {"result":0,"Account":{"id":"35","truename":null,"telephone":"18317120821","register_time":"1444716766","avatar":"0","image":null,
	// "birthday":"1970","sex":"0","logname":"wuliqing"}}
	private int id;
	private String truename;
	private String telephone;
	private long register_time;
	private String image;
	private String birthday;
	private int sex;
	private String logname;
	
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getTruename() {
		return truename;
	}

	public void setTruename(String truename) {
		this.truename = truename;
	}

	public String getTelephone() {
		return telephone;
	}

	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}

	public long getRegister_time() {
		return register_time;
	}

	public void setRegister_time(long register_time) {
		this.register_time = register_time;
	}

	public String getImage() {
		return image;
	}

	public void setImage(String image) {
		this.image = image;
	}

	public String getBirthday() {
		return birthday;
	}

	public void setBirthday(String birthday) {
		this.birthday = birthday;
	}

	public int getSex() {
		return sex;
	}

	public void setSex(int sex) {
		this.sex = sex;
	}

	public String getLogname() {
		return logname;
	}

	public void setLogname(String logname) {
		this.logname = logname;
	}

	public static UserInfo getJsonObject(JSONObject jsonObj){
		int id = 0;
		try {
			id = jsonObj.getInt("id");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		String truename = null;
		try {
			truename = jsonObj.getString("truename");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		String telephone = null;
		try {
			telephone = jsonObj.getString("telephone");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		String image = null;
		try {
			image = jsonObj.getString("image");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		String birthday = null;
		try {
			birthday = jsonObj.getString("birthday");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		String logname = null;
		try {
			logname = jsonObj.getString("logname");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		UserInfo userInfo = new UserInfo();
		userInfo.setId(id);
		userInfo.setTruename(truename);
		userInfo.setTelephone(telephone);
		userInfo.setImage(image);
		userInfo.setBirthday(birthday);
		userInfo.setLogname(logname);
		return userInfo;
	}
}
